﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Gola.VN.Scb.Web.Common.Models.UIProductModels>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Select product to compare</title>
    <style type="text/css">
        img
        {
            border: none;
        }
        .productTable
        {
            /* border: 1px solid #3399ff; */
        }
        td
        {
            vertical-align: top;
            text-align: left;
        }
        a
        {
            text-decoration: none;
        }
    </style>
    <script type="text/javascript" src="/Scripts/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="/Scripts/compare/compareProduct.js"></script>
    <script type="text/javascript">
        function displayProduct(id) {
            // 1. get data from current
            var itemCount = parent.document.getElementById('itemCount').value;
            var itemIndex = parent.document.getElementById('itemIndex').value;
            var objIds = getIds(parent.location.href);
            var arrIds = objIds.split('-');
            var strLink = '';
            
            // process data
            if (arrIds.length <= itemIndex) { // add new position
                strLink = parent.location.href + '-' + id;
                parent.document.getElementById('itemCount').value = itemCount + 1;
            }
            else { // replace a existed position
                strLink = replaceId(parent.location.href, arrIds, itemIndex, id);
            }

            // 3. close popup
            parent.location.href = strLink;
        }
    </script>
</head>
<body style="background-color:transparent">
    <table class="productTable">
        <% foreach (var product in Model.Products)
           { %>
        <tr class="productRow">
            <td style="width: 16px">
                <a href="javascript:" onclick="displayProduct('<%: product.Id %>')">
                    <img src="/Content/Images/addProduct.gif" width="16px" alt="Thêm <%:product.Title %> vào danh sách so sánh" />
                </a>
            </td>
            <td>
                <a href="<%:product.View %>">
                    <img src="<%:product.ImageUrl %>" width="64px" height="64px" alt="<%:product.Title %>" />
                </a>
            </td>
            <td>
                <a href="<%:product.View %>">
                    <%:product.Title %>
                </a>
                <br />
                <div>
                    <%:MvcHtmlString.Create(product.Description)%>
                </div>
                <br />
                <div>
                    <%:MvcHtmlString.Create(product.Promotion)%>
                </div>
            </td>
            <td>
                <div style="float: left">
                    <% if (product.Price != product.LastPrice)
                       {
                           MvcHtmlString.Create(product.LastPriceDisplay);
                       }%>
                </div>
                <div style="float: left">
                    <%:product.PriceDisplay%>
                </div>
            </td>
            <td>
                <div style="float: left">
                    <%:product.ProdiverName %>
                </div>
            </td>
        </tr>
        <%} %>
    </table>
</body>
</html>
